#include <iostream>
#include <fstream>
#include <memory>
#include <NetworkSnapshotTextDumper.h>
#include <NetworkSnapshotGraphVizDumper.h>
#include <ViewerException.h>
#include "NetworkSnapshotProviderFile.h"

/* Tests graph viz dumping and visualization */
int main(int argc, char* argv[]) {
  try {
    std::auto_ptr<INetworkSnapshotProvider> snapshotProvider(
        new NetworkSnapshotProviderFile("gvizDump.xml"));
    std::auto_ptr<INetworkSnapshotDumper> snapshotDumperText(
        new NetworkSnapshotTextDumper());
    std::auto_ptr<INetworkSnapshotDumper> snapshotDumperGrapViz(
        new NetworkSnapshotGraphVizDumper());
  
    std::auto_ptr<NetworkSnapshot> snapshot(
        snapshotProvider->getSnapshot(std::cerr));
    //snapshotDumperText->dump(std::cout, snapshot.get());
    std::ofstream out("out.fdp");
    snapshotDumperGrapViz->dump(out, snapshot.get());
  } catch(ViewerException& ex) {
    std::cerr << "Error occured: " << std::endl
              << ex.what()         << std::endl;
    exit(-1);
  }
  std::cout << "Success!" << std::endl;
  return 0;
}
